<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use App\Utils\MysqlBackup;

class BackupDatabase implements ShouldQueue
{
  use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

  private $user_id;

  /**
   * Create a new job instance.
   * @param int $user_id 用户id
   * @return void
   */
  public function __construct($user_id)
  {
    $this->user_id = $user_id;
  }

  /**
   * Execute the job.
   *
   * @return void
   */
  public function handle()
  {
    $mysqlBackup = new MysqlBackup();
    $mysqlBackup->export($this->user_id);
  }
}
